package easy

import (
	"workspace/node"
)

func Preorder(root *node.Node) []int {
	var dfs func(*node.Node)
	var ans []int
	dfs = func(node *node.Node) {
		if node == nil {
			return
		}
		ans = append(ans, node.Val)
		for _, ch := range node.Children {
			dfs(ch)
		}
	}
	dfs(root)
	return ans
}
